/* Copyright (C) 2013 Dr2co
 *
 * Created with IntelliJ IDEA.
 * User: Dr2co
 * Date: 03.07.13
 *
 *  pt-emu is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  pt-emu is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with pt-emu.  If not, see <http://www.gnu.org/licenses/>.
 */
package com.aionengine.gameserver.model.account;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author Dr2co
 */


public class AccountMembership {

    /**
     * Membership of this account
     */
    private byte membership;
    /**
     * Craftship of this account
     */
    private byte craftship;
    /**
     * Apship of this account
     */
    private byte apship;
    /**
     * Collectionship of this account
     */
    private byte collectionship;
    /**
     * The Membership expire time
     */
    private long membershipExpire;
    /**
     * The Craftship expire time
     */
    private long craftshipExpire;
    /**
     * The Apship expire time
     */
    private long apshipExpire;
    /**
     * The Collectionship expire time
     */
    private long collectionshipExpire;

    /**
     * @return the membership
     */
    public byte getMembership() {
        return membership;
    }

    /**
     * @return the membership
     */
    public byte getCraftship() {
        return craftship;
    }

    /**
     * @return the membership
     */
    public byte getApship() {
        return apship;
    }

    /**
     * @return the membership
     */
    public byte getCollectionship() {
        return collectionship;
    }

    /**
     * @param membership the membership to set
     */
    public void setMembership(byte membership) {
        this.membership = membership;
    }

    /**
     * @param craftship the membership to set
     */
    public void setCraftship(byte craftship) {
        this.craftship = craftship;
    }

    /**
     * @param apship the membership to set
     */
    public void setApship(byte apship) {
        this.apship = apship;
    }

    /**
     * @param apship the membership to set
     */
    public void setCollectionship(byte collectionship) {
        this.collectionship = collectionship;
    }

    /**
     * Sets premium expire time
     *
     * @param premiEnd sets premium expire time
     */
    public void setMembershipExpire(long expire) {
        this.membershipExpire = expire;
    }

    /**
     * Sets premium expire time
     *
     * @param premiEnd sets premium expire time
     */
    public void setCraftshipExpire(long expire) {
        this.craftshipExpire = expire;
    }

    /**
     * Sets premium expire time
     *
     * @param premiEnd sets premium expire time
     */
    public void setApshipExpire(long expire) {
        this.apshipExpire = expire;
    }

    /**
     * Sets premium expire time
     *
     * @param premiEnd sets premium expire time
     */
    public void setCollectionshipExpire(long expire) {
        this.collectionshipExpire = expire;
    }

    public String getExpire(AccountMembershipType type) {
        switch (type) {
            case REGULAR:
                if (membershipExpire != 0) {
                    return getTimeFormat(membershipExpire);
                }
                return "Never";
            case CRAFT:
                if (craftshipExpire != 0) {
                    return getTimeFormat(craftshipExpire);
                }
                return "Never";
            case AP:
                if (apshipExpire != 0) {
                    return getTimeFormat(apshipExpire);
                }
                return "Never";
            case COLLECTION:
                if (collectionshipExpire != 0) {
                    return getTimeFormat(collectionshipExpire);
                }
                return "Never";
            default:
                return "";
        }
    }

    private String getTimeFormat(long time) {
        Date date = new Date(time);
        SimpleDateFormat format = new SimpleDateFormat("dd.MM.yyyy");
        return format.format(date);
    }
}
